#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from mongokit import Document
# from api import app
from conf import test as Conf
import datetime

class Message(Document):
	__collection__ =  'message'
	__database__ = Conf.MONGODB_DATABASE
	structure = {
		'msgId':basestring,
		'date_creation': datetime.datetime,
		'master':{
			'userId': basestring,
			'isYes': bool
		},
		'slaves':[{
			'userId': basestring,
			'isYes': bool
		}],
		'pNum':int,
		'context':basestring,
	}
	default_values = {'master.isYes': True, 'pNum': 0}
	validators = {
		'context': lambda x: len(context) > 0,
		'pNum': lambda x: x in [0,3,4,5]
		}
	required = ['msgId', 'context', 'date_creation', 'master']
